import pandas as pd
import numpy as np
import torch

# 创建字典
dict_v = { 'a':0, 'b':0.25, 'c':0.5, 'd':0.75, 'e':1 }
# 用字典创建对象
sr = pd.Series( dict_v )
print(sr)
"""
a    0.00
b    0.25
c    0.50
d    0.75
e    1.00
dtype: float64
"""


# 列表示例 先定义键与值
v = [0, 0.25, 0.5, 0.75, 1]
k = ['a', 'b', 'c', 'd', 'e']
# 用列表创建对象
sr = pd.Series( v, index=k )
print(sr)
"""
a    0.00
b    0.25
c    0.50
d    0.75
e    1.00
dtype: float64
"""

# 数组示例
v = np.array([0, 0.25, 0.5, 0.75, 1])
k = ['a', 'b', 'c', 'd', 'e']
sr = pd.Series( v, index=k )
print(sr)
"""
a    0.00
b    0.25
c    0.50
d    0.75
e    1.00
dtype: float64
"""

# 张量组例
v = torch.tensor([0, 0.25, 0.5, 0.75, 1])
k = ['a', 'b', 'c', 'd', 'e']
sr = pd.Series( v, index=k )
print(sr)